<?php

namespace App\Transformers;


use App\Models\SmsRecord;
use App\Models\SmsSetting;
use League\Fractal\TransformerAbstract;

class SmsRecordTransformer extends TransformerAbstract
{
    protected $availableIncludes = ['user','fsUser'];

    public function transform(SmsRecord $smsRecord)
    {
        return [
            'id' => $smsRecord->id,
            'fs_user_id' => $smsRecord->fs_user_id,
            'carry_user_id' => $smsRecord->carry_user_id,
            'status' => $smsRecord->status,
            'value' => $smsRecord->value,
            'created_at' =>$smsRecord->created_at->toDateTimeString(),
            'updated_at' => $smsRecord->updated_at->toDateTimeString(),
        ];
    }

    public function includeUser(SmsRecord $smsRecord)
    {
        return $this->item($smsRecord->user, new UserTransformer());
    }

    public function includeFsUser(SmsRecord $smsRecord)
    {
        return $this->item($smsRecord->fsUser, new FsUserTransformer());
    }
}